package org.tis.tools.abf.module.ac.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.tis.tools.abf.module.ac.service.IAcMenuService;
import org.tis.tools.model.common.ResultVO;

import javax.validation.constraints.NotBlank;

/**
 * 对外提供查询菜单
 * Created by chenchao
 * Created on 2018/10/18 17:12
 */
@RestController
@Validated
@Api(description = "菜单对外服务")
@RequestMapping("/v1/api/acMenus")
@Slf4j
public class AcMenuApiController {

    @Autowired
    private IAcMenuService acMenuService;


    @ApiOperation(value = "查询应用下的菜单", notes = "传入应用GUID作为参数")
    @GetMapping("/{appId}/getMenusInApp")
    public ResultVO getMenusByApp(@PathVariable @NotBlank @ApiParam(value = "appId", name = "应用GUID", required = true) String appId) {
        return ResultVO.success("查询成功", acMenuService.getMenusByApp(appId));
    }

    @ApiOperation(value = "根据应用和操作员获取菜单", notes = "传入应用GUID和操作员GUID作为参数")
    @GetMapping("/{appId}/getMenusInAppOperator/{operatorId}")
    public ResultVO getMenusInAppOperator(@PathVariable @NotBlank @ApiParam(value = "appId", name = "应用GUID", required = true) String appId, @PathVariable @NotBlank @ApiParam(value = "operatorId", name = "操作员GUID", required = true) String operatorId) {
        return ResultVO.success("查询成功", acMenuService.getMenusInAppOperator(appId, operatorId));
    }
}